package question2;

import java.util.Scanner;

public class Main {

    static boolean[][] visit ;

    public  int maxAreaOfIsland(int[][] grid) {
        int m = grid.length;
        int n = grid[0].length;
        visit = new boolean[m][n];
        int result = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (!visit[i][j] && grid[i][j] == 1) {
                    int value = dfs(grid, i, j, m, n);
                    result += value > 0 ? 1 : 0;
                }
            }
        }
        return result;
    }

    static int dfs(int[][] grid, int i, int j, int m, int n) {
        if (i < 0 || i >= m || j < 0 || j >= n || grid[i][j] == 0 || visit[i][j]) {
            return 0;
        }
        int count = 1;
        visit[i][j] = true;
        int[] x = {0, 0, 1, -1};
        int[] y = {1, -1, 0, 0};
        for (int k = 0; k < x.length; k++) {
            count += dfs(grid, i + x[k], j + y[k], m, n);
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] rows = line.split("\\|");
        int[][] matrix = new int[rows.length][rows.length];
        for(int i = 0; i < rows.length; i++) {
            String[] array = rows[i].split(" ");
            for(int j = 0; j < rows.length; j++) {
                matrix[i][j] = Integer.valueOf(array[j]);
            }
        }
        int result = new Main().maxAreaOfIsland(matrix);
        System.out.println(result);
    }
}
